
//CREATE
function createHttpRequest() {
var httpRequest;
var browser = navigator.appName;

if (browser == "Microsoft Internet Explorer") {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
} else {
httpRequest = new XMLHttpRequest();
}

return httpRequest;
}






//SEND VIA GET
function sendGETreq(info, file, _resultId, getRequestProc) {
resultId = _resultId;
document.getElementById(resultId).innerHTML = 'Please wait, loading';
httpRequest.open('get', file + "?" + info , true);
httpRequest.onreadystatechange = getRequestProc;
httpRequest.send(null);
}


//SEND VIA POST
function sendPOSTreq(info, file, _resultId, getRequestProc) {
resultId = _resultId;
inform = info.split(" ");
document.getElementById(resultId).innerHTML = 'Please wait, loading...';
httpRequest.open('POST', file, true);
httpRequest.setRequestHeader(
    'Content-Type',
    'application/x-www-form-urlencoded; charset=UTF-8'
);
//alert("dodo1");
httpRequest.onreadystatechange = getRequestProc;
//alert("dodo2");
httpRequest.send(info);
//alert("dodo3");
}

// Post for map
function sendPOSTreqMap(info, file, _resultId, getRequestProc)
{
    
    resultId = _resultId;
    inform = info.split(" ");
    httpRequest.open('POST', file, true);
    httpRequest.setRequestHeader(
    'Content-Type',
    'application/x-www-form-urlencoded; charset=UTF-8'
    );   
    httpRequest.onreadystatechange = getRequestProc;
    httpRequest.send(info);
}



//GET
function getcom() {
if (httpRequest.readyState == 4){
   if (httpRequest.status == 200){
      strok = String(httpRequest.responseText).replace(/(\r|\n)/g,'');
      switch (strok.substr(0,6)){
      case '/redir':
        window.location.href=httpRequest.responseText.substr(7);
        break;
      case '/succs':
        document.getElementById(resultId).innerHTML = 'Successfull, redirecting...';
        window.location.href=httpRequest.responseText.substr(7);
        break;
      default:
        document.getElementById(resultId).innerHTML = httpRequest.responseText;
        break;
           }
          }
       }

}

var httpRequest = createHttpRequest();
var resultId = '';


//REDIRECT

//

//////STUFF NOT AJAX
   function knowpoll(form){
   for(i=0; i < formPoll.elements.length; i++) {
   if(form.elements[i].type=='radio'){
   if(form.elements[i].checked)
   {
   var chek = form.elements[i].value;

   return chek;
   }
   }
   }
   }

   function getSex(){
        for(i=0; i<document.formReg.REGSex.length; i++){
                if(document.formReg.REGSex[i].checked){
                var sex = document.formReg.REGSex[i].value;
                 return sex;
                 }
        }
}
